/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package cs575.coresystem;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.sql.Timestamp;
/**
 *
 * @author bms
 */
public class Utils {
    
    private static final DateFormat format = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
        
    public static Timestamp dateFormat(Date rawData) throws DateConversionException
    {
        Timestamp time = null;
        try{
            time = new Timestamp(rawData.getTime()); 
        }
        catch(Exception e){
            throw new DateConversionException();
        }
        return time;
    }
    
    public static Timestamp dateFormat(String strData) throws DateConversionException
    {
        Timestamp time = null;
        try{
            time = new Timestamp(format.parse(strData).getTime()); 
        }
        catch(Exception e){
            throw new DateConversionException();
        }
        return time;
    }
    
    public static Timestamp dateFormat(Timestamp strData) throws DateConversionException
    {
        Timestamp time = null;
        try{
            time = new Timestamp(format.parse(strData.toString()).getTime()); 
        }
        catch(Exception e){
            throw new DateConversionException();
        }
        return time;
    }
}
